package com.meiyou.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.meiyou.pojo.Chongzhi;
import com.meiyou.pojo.JuBao;
import com.meiyou.pojo.MeiyouGuide;
import com.meiyou.pojo.MeiyouTour;
import com.meiyou.pojo.MeiyouTuina;
import com.meiyou.pojo.MeiyouYuehui;
import com.meiyou.pojo.Tixian;
import com.meiyou.pojo.vo.UserVo;

public class PagesMap {
	
	public static Map<String,Object> getpagesUserMaps(List<UserVo> list,int pn){
		 List<UserVo> newList = new ArrayList<UserVo>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size());
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	        
	        int total = list.size();   
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
	}
	
	
	public static Map<String,Object> getpagesJubaoMaps(List<JuBao> list,int pn){
		 List<JuBao> newList = new ArrayList<JuBao>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	     
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
	}
	
	
	public static Map<String,Object> getpagesChongzhiMaps(List<Chongzhi> list,int pn){
		 List<Chongzhi> newList = new ArrayList<Chongzhi>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
	}
	
	
	public static Map<String,Object> getpagesTixianMaps(List<Tixian> list,int pn){
		 List<Tixian> newList = new ArrayList<Tixian>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
	}
	public static Map<String,Object> getpagesYuiHuiMaps(List<MeiyouYuehui> list,int pn){
		 List<MeiyouYuehui> newList = new ArrayList<MeiyouYuehui>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
	}
	public static Map<String,Object> getpagesTourMaps(List<MeiyouTour> list,int pn){
		 List<MeiyouTour> newList = new ArrayList<MeiyouTour>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
}
	public static Map<String,Object> getpagesGuideMaps(List<MeiyouGuide> list,int pn){
		 List<MeiyouGuide> newList = new ArrayList<MeiyouGuide>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
}
	public static Map<String,Object> getpagesTuiNaMaps(List<MeiyouTuina> list,int pn){
		 List<MeiyouTuina> newList = new ArrayList<MeiyouTuina>();
	        if(20*pn>list.size()) {
	        	newList = list.subList(20*pn-19-1,list.size()); 
	        }else {
	        	newList = list.subList(20*pn-19-1, 20*pn);  
	        }
	        
	        Map<String,Object> map = new HashMap<String,Object>();
	     
	        int total = list.size();  
	        int pageNum = pn;          
	        int pages = total%20 == 0 ? (total/20) : (total/20)+1;   
	        int[] navigatepageNums = new int[pages];      
	        for(int i=0;i<navigatepageNums.length;i++) {
	        	navigatepageNums[i]=i+1;	        			
	        }
	        boolean hasNextPage = false;
	        if(pn==pages) {
	        	hasNextPage = false;
	        }else {
	        	hasNextPage = true;
	        }
	        boolean hasPreviousPage = false;
	        if(pn==1) {
	        	hasPreviousPage = false;
	        }else {
	        	hasPreviousPage = true;
	        }
	        map.put("total", total);
	        map.put("pageNum", pageNum);
	        map.put("pages", pages);
	        map.put("navigatepageNums", navigatepageNums);
	        map.put("hasNextPage", hasNextPage);
	        map.put("list", newList);
	        map.put("hasPreviousPage", hasPreviousPage);
	        return map;
}
	
}
